package me.skyun.androidarch.base;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Created by linyun on 16/11/17.
 */
public abstract class BaseFragment extends Fragment {
    @Inherited
    @Documented
    @Target(ElementType.TYPE)
    @Retention(RetentionPolicy.RUNTIME)
    public @interface Attr {
        int contentViewResId();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        Attr attr = getClass().getAnnotation(Attr.class);
        int contentViewResId = attr.contentViewResId();
        View view = inflater.inflate(contentViewResId, null);
        return view;
    }
}
